home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 …SCII & the Runetime Code / ADC Developer CD (1992-07) (''Butch ASCII And The Runtime Code'')_iso / Dev.CD 199207.iso / Development Platforms / HyperCard Related / XCMDs & XFCNs / Help XFCN / source / trap.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-19  |  2.1 KB  |  99 lines  |  [TEXT/MPS ]

  1. /*
  2.     trap.c
  3.     Functions to support testing for traps
  4.     and testing for Gestalt features.
  5.     
  6.     11-13-90 1.0d3 JRP    original (for Alias XFCN)
  7.     11-14-90 1.0d1 JRP    add helpMgrPresent
  8.                         change aliasAvailable to aliasMgrPresent
  9. */
  10.  
  11. #include    <Types.h>
  12. #include    <Traps.h>
  13. #include    <OSUtils.h>
  14. #include    <GestaltEqu.h>
  15.  
  16. #include    "trap.pro"
  17.  
  18. short helpMgrPresent(void)
  19. /*
  20.     Returns true if the Help Manager is present.
  21. */
  22. {
  23.     if(gestaltAvailable())
  24.         return(Gestalt(gestaltHelpMgrAttr, gestaltHelpMgrPresent)==noErr);
  25.     else
  26.         return false;
  27. }    /*    --------------------------------------------    helpMgrPresent        */
  28.  
  29. short aliasMgrPresent(void)
  30. /*
  31.     Returns true if Alias Manager is present.
  32. */
  33. {
  34.     if(gestaltAvailable())
  35.         return(Gestalt(gestaltAliasMgrAttr, gestaltAliasMgrPresent)==noErr);
  36.     else
  37.         return false;
  38. }    /*    --------------------------------------------    aliasMgrPresent        */
  39.  
  40. short gestaltAvailable(void)
  41. /*
  42.     Returns true if gestalt is available.
  43.     From IM-VI. chap 3, page 8
  44. */
  45. {
  46.     #define    _Gestalt    0xA1AD
  47.     
  48.     return(trapAvailable(_Gestalt));
  49. }    /*    --------------------------------------------    gestaltAvailable        */
  50.  
  51. short getTrapType(theTrap)
  52. /*
  53.     Returns the trap type.
  54.     From IM-VI. chap 3, page 8
  55. */
  56.     short    theTrap;
  57. {
  58.     #define    trapMask    0x0800
  59.     
  60.     if(theTrap & trapMask)
  61.         return ToolTrap;
  62.     else
  63.         return OSTrap;
  64. }    /*    --------------------------------------------    getTrapType        */
  65.  
  66. short numToolboxTraps(void)
  67. /*
  68.     Returns the number of toolbox traps.
  69.     From IM-VI. chap 3, page 8
  70. */
  71. {
  72.     if(NGetTrapAddress(_InitGraf, ToolTrap)==
  73.             NGetTrapAddress(0xAA6E, ToolTrap))
  74.                 return 0x200;
  75.     else
  76.         return 0x400;
  77. }    /*    --------------------------------------------    numToolboxTraps        */
  78.  
  79. short trapAvailable(theTrap)
  80. /*
  81.     Returns true if the trap is available.
  82.     From IM-VI. chap 3, page 8
  83. */
  84.     short    theTrap;
  85. {
  86.     short    tType;
  87.  
  88.     tType = getTrapType(theTrap);
  89.     if(tType==ToolTrap)
  90.     {
  91.         theTrap = theTrap & 0x07FF;
  92.         if(theTrap>=numToolboxTraps())
  93.             theTrap = _Unimplemented;
  94.     }
  95.     return(NGetTrapAddress(theTrap, tType)!=
  96.                 NGetTrapAddress(_Unimplemented, ToolTrap));
  97. }    /*    --------------------------------------------    trapAvailable    */
  98.  
  99.